#!/usr/bin/env python 
#-------------------------------------------------------------------------------
# Name:        module3
# Purpose:
#
# Author:      feim
#
# Created:     01/08/2012
# Copyright:   (c) feim 2012
# Licence:     <your licence>
#-------------------------------------------------------------------------------
import PIL, Image
import os

#f = open("sfdump003_layer1_480x800_RGBA_8888.raw","rb")
#f = open("sfdump001_layer1_544x960_RGBA_8888.raw","rb")
os.system("adb shell dd if=/dev/graphics/fb0 of=/data/fb.raw")
os.system("adb pull /data/fb.raw");
f = open("fb.raw","rb")

data = f.read()
print f, "length:", len(data), type(data)
f.close()

img = Image.fromstring("RGBA", (480,800*3), data)

print img.mode
r,g,b,a = img.split()
img2 = Image.merge("RGB", (r, g, b))

img2.save("fb0.png")

os.system("display fb0.png")

def main():
    pass

if __name__ == '__main__':
    main()
